﻿using Easy.Cloud.Communication.Sms.Core;
using Easy.Cloud.Communication.Sms.Tencent.Options;
using Microsoft.Extensions.Configuration;
using System;

namespace Easy.Cloud.Communication.Sms.Tencent
{
    public static class SmsOptionsExtensions
    {
        public static SmsOptions UseTencent(this SmsOptions options, IConfiguration configuration, string configName = SmsConst.DefaultOptionSelectName + "TencentOptions")
        {
            var option = configuration.GetSection($"{configName}").Get<TencentOptions>(); ;

            if (option is null)
                throw new ArgumentNullException(nameof(option));

            options.RegisterExtension(new TencentSmsOptionsExtension(option));

            return options;
        }
    }
}
